require(['jquery', 'cookie', 'app', 'lay'], function ($) {
    require(['vue'], function (Vue) {
        layui.use(['form','laydate','upload'], function() {
            var form = layui.form;
            form.on('submit(formDemo)', function(data){
                dic.that.startTime=data.field.startTime;
                dic.that.endTime=data.field.endTime;
                var dt=dic.that;
                dt['note']=JSON.stringify(dt['note']);
                dt["status"]="ING";
                var re=playAjax("/ShopController/ActiveSave",dt);
                alr(re.msg);
                dic.referXadmin();
                return false;
            });
            var laydate = layui.laydate;
            laydate.render({
                elem: '#startTime',
                type:"datetime"
            });
            laydate.render({
                elem: '#endTime',
                type:"datetime"
            });
            var upload = layui.upload;

            //执行实例
            var uploadInst = upload.render({
                elem: '#upload' //绑定元素
                , url: configPro.server_img_interface //上传接口
                , done: function (res) {
                    dic.that.note.push(res.data.src);
                }
                , error: function (res) {
                    alr("上传失败");
                }
                , accept: 'file'
            });
        });
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where: [],
                that: {
                    uuid:"",
                    name:"",
                    startTime:"",
                    endTime:"",
                    note:[]
                }
            }
            , created: function () {
                var uuid=new acquire().parameterMap['uuid'];
                if(uuid!=null){
                    this.that=playAjax("ShopController/GetActive",{uuid:uuid}).data;
                    this.that.note=JSON.parse(this.that.note);
                }

            }
            , methods: {
                delNote:function (i) {
                    var re = this.that.note;
                    re.splice(i,1);
                    this.that.note=re;
                },
                referXadmin: function () {
                    window.location.reload();
                },
            }
        });
    })
});
